package com.nantai.jiafang.nantaijiafang.activity;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.nantai.jiafang.nantaijiafang.R;
import com.nantai.jiafang.nantaijiafang.bean.FabricBatchInfo;
import com.nantai.jiafang.nantaijiafang.bean.ProductionOrderInfo;

public class DataSearchDetailActivity extends AppCompatActivity {

    private TextView tv_back;
    private String type = "1";
    private ProductionOrderInfo info1;
    private FabricBatchInfo info2;
    private LinearLayout ll_1;
    private TextView tv1_1, tv1_2, tv1_3, tv1_4, tv1_5, tv1_6, tv1_7, tv1_8, tv1_9, tv1_10;
    private LinearLayout ll_2;
    private TextView tv2_1, tv2_2, tv2_3, tv2_4, tv2_5, tv2_6, tv2_7, tv2_8;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_data_search_detail);
        type = getIntent().getStringExtra("type");
        if (type.equals("1")) {
            info1 = (ProductionOrderInfo) getIntent().getSerializableExtra("info");
        } else {
            info2 = (FabricBatchInfo) getIntent().getSerializableExtra("info");
        }

        initViews();
    }

    private void initViews() {
        tv_back = (TextView) findViewById(R.id.tv_back);
        tv_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        ll_1 = (LinearLayout) findViewById(R.id.ll_1);
        tv1_1 = (TextView) findViewById(R.id.tv1_1);
        tv1_2 = (TextView) findViewById(R.id.tv1_2);
        tv1_3 = (TextView) findViewById(R.id.tv1_3);
        tv1_4 = (TextView) findViewById(R.id.tv1_4);
        tv1_5 = (TextView) findViewById(R.id.tv1_5);
        tv1_6 = (TextView) findViewById(R.id.tv1_6);
        tv1_7 = (TextView) findViewById(R.id.tv1_7);
        tv1_8 = (TextView) findViewById(R.id.tv1_8);
        tv1_9 = (TextView) findViewById(R.id.tv1_9);
        tv1_10 = (TextView) findViewById(R.id.tv1_10);

        ll_2 = (LinearLayout) findViewById(R.id.ll_2);
        tv2_1 = (TextView) findViewById(R.id.tv2_1);
        tv2_2 = (TextView) findViewById(R.id.tv2_2);
        tv2_3 = (TextView) findViewById(R.id.tv2_3);
        tv2_4 = (TextView) findViewById(R.id.tv2_4);
        tv2_5 = (TextView) findViewById(R.id.tv2_5);
        tv2_6 = (TextView) findViewById(R.id.tv2_6);
        tv2_7 = (TextView) findViewById(R.id.tv2_7);
        tv2_8 = (TextView) findViewById(R.id.tv2_8);

        if (type.equals("1")) {
            ll_1.setVisibility(View.VISIBLE);
            ll_2.setVisibility(View.GONE);
            tv1_1.setText(info1.getDocNo());
            tv1_2.setText(info1.getcInvName());
            tv1_3.setText(info1.getcInvAddCode());
            tv1_4.setText(info1.getComponentInvName());
            tv1_5.setText(info1.getComponentInvCode());
            tv1_6.setText(info1.getcVenCode());
            tv1_7.setText(info1.getLevels());
            tv1_8.setText(info1.getCutCost());
            tv1_9.setText(info1.getPickLength());
            tv1_10.setText(info1.getUseRatePercentText());

        } else {
            ll_1.setVisibility(View.GONE);
            ll_2.setVisibility(View.VISIBLE);
            tv2_1.setText(info2.getComponentInvName());
            tv2_2.setText(info2.getComponentInvCode());
            tv2_3.setText(info2.getcVenCode());
            tv2_4.setText(info2.getcBatch());
            tv2_5.setText(info2.getLevels());
            tv2_6.setText(info2.getCutCost());
            tv2_7.setText(info2.getPickLength());
            tv2_8.setText(info2.getUseRatePercentText());
        }


    }
}
